/*
 * @Author: venom
 * @Date: 2021-08-08 14:43:14
 * @LastEditors: BuddyCoder
 * @LastEditTime: 2022-11-10 20:48:29
 * @Description: 
 * @FilePath: /pgbatis/tests/curd_test.rs
 * MIT
 */
 #[cfg(test)]
 mod test { 
    // use std::collections::hash_map::RandomState;
    // use std::collections::HashMap;

    // use chrono::{DateTime, Utc};
    // use serde::de::DeserializeOwned;
    use serde::Deserialize;
    use serde::Serialize;
  //  use actix_rt;
    use pgbatis;
  //  use pgbatis::DATABASE_POOL;

    use pgbatis::pgmacro::PGCRUD;
    use pgbatis::Parameters;
    use pgbatis::ColumnExt;
    use pgbatis::tokio_postgres::types::ToSql;
    use pgbatis::tokio_postgres::Row;
    

  //  use pgbatis::Wrapper;
  //   #[derive(PGCRUD,Serialize, Deserialize, Clone, Debug,Default)]
  //   pub struct Test1 {
  //     pub id: Option<String>,
  //     pub column1: Option<i32>,
  //     pub column2: Option<bool>,
  //     pub column3: Option<f32>,
  // }



    //  #[actix_rt::test]
    //  async  fn test_ids() {
    //     let link = "postgresql://venom_db_admin:IUF76YUguiffy8FU@47.106.81.32/venom_database";
    //     DATABASE_POOL.link(link).await.unwrap(); 
    // }
    //打印语句输出，可以使用 cargo test test_with_fixture -- --nocapture：
    //#[test]
    // fn test_save() {
    //     let s:Option<&str> = Some("helloword");

    //    let mut test = BizActivity::default();
    //    test.id = Some(String::from("1234567890"));
    //    test.name = Some(String::from("name_o"));
    //    let  (sql,args) = test.save(None).unwrap();
    //    println!("sql :{}",sql);
    //    println!("args :{:?}",args);
    // }

    // #[test]
    // fn test_update() {
    //    let mut test = BizActivity::default();
    //    test.id = Some(String::from("1234567890"));
    //    test.name = Some(String::from("name_o"));
    //    let  (sql,args,args_no) = test.update(None,None).unwrap();
    //    println!("sql :{}",sql);
    //    println!("args :{:?}",args);
    //    println!("args_no :{:?}",args_no);
    // }
    #[derive(Serialize, Deserialize, Clone, Debug,Default,PGCRUD)]
    pub struct BizActivity {
        pub id: Option<String>,
        pub name: Option<String>,
        pub pc_link: Option<String>,
    }  
  //  fn get_table_name(prefix: Option<String>, suffix:Option<String>) -> String {
  //     let temp_table_name = match prefix {
  //          Some(t) => format!("{}_{}",t,"table_name"),
  //          None => format!("{}","table_name")
  //      };
  //     match  suffix {
  //         Some(t)=> format!("{}_{}",temp_table_name,t),
  //         None => format!("{}",temp_table_name)
  //     }
  //  }
   
    #[test]
    fn test_get_table_name() {
       let mut test = BizActivity::default();
       test.id = Some(String::from("1234567890"));
       test.name = Some(String::from("name_o"));
       let table_name = BizActivity::get_table_name(None,None);
       println!("get_table_name :{}",table_name);  
    }
    // #[actix_rt::test]
    // async fn save(){
    //   let mut test = Test1::default();
    //   test.id = Some(String::from("1234567890"));
    //   test.column1 = Some(999);
    //   test.column2 = Some(false);
    //   test.column3 = Some(9.9199);
     
    //  let _r =  pgbatis::link("127.0.0.1",5432,"venom_db_admin","12345677","venom_database",2).await;
    //  let r = pgbatis::save(test,None).await;
    //  println!("result:{:?}",r)
    // }



    
  
}
